<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="80px">
      <el-form-item label="工单ID" prop="orderId" label-width="70px">
        <el-input
          v-model="queryParams.orderId"
          :disabled="true"
        />
      </el-form-item>
      <el-form-item label="产品名称" prop="materialName">
        <el-input v-model="queryParams.materialName" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" border>
      <el-table-column label="工单编码" align="center" prop="orderCode" />
      <el-table-column label="计划编码" align="center" prop="planCode" />
      <el-table-column label="产品编码" align="center" prop="materielid" />
      <el-table-column label="产品名称" align="center" prop="materialName" />
      <el-table-column label="所需数量" align="center" prop="kitquantity" />
      <el-table-column label="wms库存数量" align="center" prop="quantity" />
      <el-table-column label="差异数量" align="center" prop="variancequantity" />
      <el-table-column label="单位" align="center" prop="unit" />
    </el-table>
    <pagination
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<script>
  import { listQTInfo } from '@/api/function/qtInfo';
  export default {
    name: "qtInfo",
    props: {
      orderId: {
        type: Number,
        default: 0,
      },
    },
    watch: {
      orderId: {
        handler(newVal, oldVal) {
          if (newVal) {
            this.queryParams.orderId = newVal;
            this.defaultOrderId = newVal;
            this.getList();
          }
        },
        immediate: true,
        deep: true,
      },
      
    },
    created() { },
    data() {
      return {
        // 总条数
        total: 0,
        // 字典表格数据
        dataList: [],
        // 默认id
        defaultOrderId: 0,
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
        },
      };
    },
    created() {},
    mounted() {},
    methods: {
      /** 查询齐套详情列表 */
      getList() {
        this.loading = true;
        listQTInfo(this.queryParams).then((response) => {
          this.dataList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.queryParams.orderId = this.defaultOrderId;
        this.handleQuery();
      },
    },
  };
</script>
